home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_Tix.idb / usr / freeware / lib / tix4.1 / demos / samples / CmpImg4.tcl.z / CmpImg4.tcl
Encoding:
Text File  |  1999-01-26  |  4.0 KB  |  122 lines

  1. # Tix Demostration Program
  2. #
  3. # This sample program is structured in such a way so that it can be
  4. # executed from the Tix demo program "widget": it must have a
  5. # procedure called "RunSample". It should also have the "if" statment
  6. # at the end of this file so that it can be run as a standalone
  7. # program using tixwish.
  8.  
  9. # This file demonstrates how to use the compound image to add
  10. # colors in Notebook tabs.
  11. #
  12. proc RunSample {w} {
  13.  
  14.     # Create the notebook widget and set its backpagecolor to gray.
  15.     # Note that the -backpagecolor option belongs to the "nbframe"
  16.     # subwidget.
  17.     tixNoteBook $w.nb -ipadx 6 -ipady 6
  18.     $w config -bg gray
  19.     $w.nb subwidget nbframe config -backpagecolor gray -tabpady 0
  20.  
  21.     # Create the two compound images --
  22.     #
  23.     # Create the first image:
  24.     #
  25.     # Notice that the -window option must be set to the nbframe
  26.     # subwidget of the notebook because the image will be displayed
  27.     # in that widget.
  28.     #
  29.     set hdd_img [image create compound -window [$w.nb subwidget nbframe] \
  30.     -pady 4 -padx 4 -bg #f09090 -showbackground 1]
  31.     $hdd_img add line
  32.     $hdd_img add text -text "Hard Disk" -underline 0 -padx 6 -pady 4
  33.  
  34.     # Create the second compound image. Very similar to what we did above
  35.     #
  36.     set net_img [image create compound -window [$w.nb subwidget nbframe] \
  37.     -pady 4 -pady 4 -bg #9090f0 -showbackground 1]
  38.     $net_img add line
  39.     $net_img add text -text "Network" -underline 0 -padx 6 -pady 4
  40.  
  41.     #
  42.     # Now create the pages
  43.     #
  44.  
  45.     # We use these options to set the sizes of the subwidgets inside the
  46.     # notebook, so that they are well-aligned on the screen.
  47.     #
  48.     set name [tixOptionName $w]
  49.     option add *$name*TixControl*entry.width 10
  50.     option add *$name*TixControl*label.width 18
  51.     option add *$name*TixControl*label.anchor e
  52.  
  53.     # Create the two tabs on the notebook. The -underline option
  54.     # puts a underline on the first character of the labels of the tabs.
  55.     # Keyboard accelerators will be defined automatically according
  56.     # to the underlined character.    
  57.     #
  58.     $w.nb add hard_disk -image $hdd_img
  59.     $w.nb add network   -image $net_img
  60.     pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top
  61.  
  62.     #----------------------------------------
  63.     # Create the first page
  64.     #----------------------------------------
  65.     set f [$w.nb subwidget hard_disk]
  66.  
  67.     # Create two frames: one for the common buttons, one for the
  68.     # other widgets
  69.     #
  70.     frame $f.f
  71.     frame $f.common
  72.     pack $f.f      -side left  -padx 2 -pady 2 -fill both -expand yes
  73.     pack $f.common -side right -padx 2 -pady 2 -fill y
  74.  
  75.     # Create the controls that only belong to this page
  76.     #
  77.     tixControl $f.f.a -value 12   -label "Access Time: "
  78.     tixControl $f.f.w -value 400  -label "Write Throughput: "
  79.     tixControl $f.f.r -value 400  -label "Read Throughput: "
  80.     tixControl $f.f.c -value 1021 -label "Capacity: "
  81.     pack $f.f.a $f.f.w $f.f.r $f.f.c  -side top -padx 20 -pady 2
  82.  
  83.     # Create the common buttons
  84.     #
  85.     CreateCommonButtons $w $f.common
  86.     
  87.     #----------------------------------------
  88.     # Create the second page    
  89.     #----------------------------------------
  90.     set f [$w.nb subwidget network]
  91.  
  92.     frame $f.f
  93.     frame $f.common
  94.     pack $f.f      -side left  -padx 2 -pady 2 -fill both -expand yes
  95.     pack $f.common -side right -padx 2 -pady 2 -fill y
  96.  
  97.     tixControl $f.f.a -value 12   -label "Access Time: "
  98.     tixControl $f.f.w -value 400  -label "Write Throughput: "
  99.     tixControl $f.f.r -value 400  -label "Read Throughput: "
  100.     tixControl $f.f.c -value 1021 -label "Capacity: "
  101.     tixControl $f.f.u -value 10   -label "Users: "
  102.  
  103.     pack $f.f.a $f.f.w $f.f.r $f.f.c $f.f.u -side top -padx 20 -pady 2
  104.  
  105.     CreateCommonButtons $w $f.common
  106. }
  107.  
  108. proc CreateCommonButtons {w f} {
  109.     button $f.ok     -text OK     -width 6 -command "destroy $w"
  110.     button $f.cancel -text Cancel -width 6 -command "destroy $w"
  111.  
  112.     pack $f.ok $f.cancel -side top -padx 2 -pady 2
  113. }
  114.  
  115. if {![info exists tix_demo_running]} {
  116.     wm withdraw .
  117.     set w .demo
  118.     toplevel $w
  119.     RunSample $w
  120.     bind .demo <Destroy> exit
  121. }
  122.